package com.tao.utilslib.os;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;

public class AppUtils {
    public static<T extends Activity>  void launcherNewActivity(Context context, Class<T> activityClass) {
        Intent intent = new Intent(context, activityClass);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
    }

    public static <T extends Activity> void launcherActivity2Top(Context context, Class<T> activityClass) {
        launcherActivity(context, activityClass, Intent.ACTION_MAIN , Intent.CATEGORY_LAUNCHER, Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
    }

    public static <T extends Activity> void launcherActivity(Context context, Class<T> activityClass, String action, String categorys, int flags) {
        Intent intent = new Intent(context, activityClass);
        intent.addCategory(categorys);
        intent.setAction(action);
        intent.setFlags(flags);
        context.startActivity(intent);
    }

    public static boolean isTop(Context context ) {
            return context.getPackageName().equals(OsUtils.getTopProcessPackageName(context));
     
    }
}
